package com.jcfk.system.controller;

import com.jcfk.common.web.domain.RetResult;
import com.jcfk.system.service.SysDictionaryItemService;
import com.jcfk.system.utils.mail.JavaMailUntil;
import com.jcfk.system.domain.dto.MailAttachmentDTO;
import com.jcfk.system.domain.dto.MailInfoDTO;
import com.jcfk.system.utils.mail.MailHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.mail.*;
import javax.mail.internet.*;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 邮件服务
 *
 * @author 李炳海
 * @date 2021/10/16 19:47
 */
@RestController
@RequestMapping("mail")
public class SendMailController {

    @Autowired
    private MailHelper helper;


    /**
     * 发送邮件
     */
    @PostMapping("sendEmail")
    public RetResult<?> sendEmail(@RequestBody MailInfoDTO mailInfoDTO) throws MessagingException, IOException {

        return helper.sendEmail(mailInfoDTO);
    }

}
